﻿using System.Collections.Generic;
using System.Linq;

namespace IBBI.DataBase.Enumeration {

    public sealed class UserRoles {

        public static readonly Role SuperAdmin   = new Role(0,  "Super",                 "超级管理员");
        public static readonly Role Admin        = new Role(1,  "Adminstrator",          "管理员");
        public static readonly Role VedioAdmin   = new Role(2,  "Vedio Administrator",   "视屏管理员");
        public static readonly Role ArticleAdmin = new Role(3,  "Article Administrator", "视屏管理员");
        public static readonly Role Member       = new Role(11, "Member",                "普通会员");
        public static readonly Role Vip          = new Role(99, "VIP",                   "VIP会员");

        public static readonly List<Role> All = new List<Role>(
            new[] {
                SuperAdmin, 
                Admin, 
                VedioAdmin, 
                ArticleAdmin, 
                Member, 
                Vip
            }
        );

        public static readonly Dictionary<int, Role> Map = All.ToDictionary(role => role.Value);

        public static Role GetUserRole(int role) {
            return Map[role];
        }
        
        public static bool IsSuper(Role role) {
            return SuperAdmin.Equals(role);
        }

        public static bool IsAdmin (Role role) {
            return Admin.Equals(role);
        }
    }
}